<template>
  <div>
  <el-dialog
  v-model="DialogVisible"
  width="40%"
  :before-close="handleClose">

  <template #header>
    <div style="text-align: center; margin-top: -1.3vw;">
    <img src="@/assets/images/title_bg.png" alt="">
    <div style="margin-top: -4.5%;color: aliceblue;font-size: 16px;">使用反馈</div>
  </div>
  </template>

  <el-form :model="form"
           style="margin-top: 5%;">
    <el-form-item label="问题类型：" :label-width="formLabelWidth">
      <el-select v-model="form.region" placeholder="请选择问题类型" class="select" style="width: 25vw;">
        <el-option label="使用速度慢" value="使用速度慢"></el-option>
        <el-option label="回答异常" value="回答异常"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="反馈内容：" :label-width="formLabelWidth">
      <el-input type="textarea" v-model="form.name" autocomplete="off" style="width: 45vw;"></el-input>
    </el-form-item>
    <el-form-item label="评分：" :label-width="formLabelWidth">
      <el-rate v-model="form.star" show-score text-color="#ff9900" score-template="{value}"></el-rate>
    </el-form-item>
  </el-form>
   
  <template #footer>
    <el-button type="primary" round @click="HandleConfirm" style="width: 6vw;">提 交</el-button>
    <el-button @click="DialogVisible = false" round style="width: 6vw;">取 消</el-button>
  </template>
</el-dialog>
</div>
</template>
<script>
import { userSuggest } from '@/api/chartdb';
export default {
    data() {
      return {
        DialogVisible: false,
        form: {
          name: '',
          region: '',
          star: 0,
          type: [],
        },
        formLabelWidth: '120px',
      };
    },
    methods: {
      openDialog(tb) {
        this.DialogVisible = true;
      },
      handleClose() {
        this.DialogVisible = false;
      },
      HandleConfirm() {
        this.DialogVisible = false; // 关闭弹窗
        // this.$emit("exeUseAct")

        var par = {
        starLevel: this.form.star,
        message: this.form.message,
        messageType: this.form.type
      }
      userSuggest(par).then((respos) => {
        const res = respos.data
        if (res == 'success') {
          this.$message({
            type: 'SUCCESS',
            message: '反馈成功!'
          })
        } else {
          this.$message.error(res)
        }
        console.log(res)
      })
      }
    },
  };
</script>
<style >
</style>